package com.shjn.squirrel.application;

import android.app.Application;

import com.shjn.squirrel.bean.storageBean.Location;
import com.shjn.squirrel.model.LocalStorage;
import com.shjn.squirrel.utils.AppCrashUtils;
import com.shjn.squirrel.utils.DeviceUtils;
import com.shjn.squirrel.utils.SoundPlayUtils;

/**
 * 应用程序初始化
 */
public class MyApplication extends Application {

    private static MyApplication instance;

    public static MyApplication getInstance() {
        return instance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        String appProcessName = DeviceUtils.getAppProcessName(this, DeviceUtils.getAppProcessId());
        //初始化主进程
        if (appProcessName != null && appProcessName.equals("com.shjn.squirrel")) {
            //监听App崩溃信息
            AppCrashUtils.startListener();
            //关闭状态栏，导航栏
//            CloseBarUtils.closeBar();
            //初始化SoundPlayUtil
            SoundPlayUtils.init(this);
            //开启GPS数据监听
            LocalStorage.saveLocation(this, new Location(121.234678, 31.256987));//模拟获取GPS数据
//            GPSUtils.startGPSListener(this, new GPSUtils.OnLocationChangedListener() {
//            @Override
//            public void onLocationChanged(android.location.Location location) {
//                Log.i("info","经度："+location.getLongitude());
//                Log.i("info","纬度："+location.getLatitude());
//                LocalStorage.saveLocation(MyApplication.this,new Location(location.getLongitude(),location.getLatitude()));
//                //只监听一次
//                GPSUtils.removeGPSListener();
//            }
//        });
        }
    }

}
